<?php

namespace App\Winged\Seeds;

use Encore\Admin\Auth\Database\Role;
use Illuminate\Database\Seeder;
use Encore\Admin\Auth\Database\Menu;
use Illuminate\Support\Facades\DB;

class WingedAdminTablesSeeder extends Seeder
{
    /**
     * @var array
     */
    private $moduleSeeders = [
        \App\Winged\Auth\AuthSeeder::class,
        \App\Winged\Patients\PatientsSeeder::class,
        \App\Winged\Evaluation\EvaluationSeeder::class,
    ];
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $this->init();
        $this->callModuleSeeders();
    }

    private function callModuleSeeders()
    {
        for ($i = 0; $i < count($this->moduleSeeders); $i++)
        {
            $this->call($this->moduleSeeders[$i]);
        }
    }

    private function init()
    {
        // 清空所有数据表
        Menu::truncate();// 清空菜单表
        Role::truncate();// 清空角色表
        DB::table('admin_role_menu')->truncate();//清空菜单－角色关联表
    }
    
}
